﻿#pragma once

#include "Misc/EngineEditorMacros.h"
#include "Object/Object.h"
#include "EditorPageModel.h"
#include "EditorPageViewModel.m.h"

class REditorPageModel;
class RTexture2D;

RCLASS()
class REditorPageViewModel : public RObject
{
    ROBJECT

public:
    //get the width of the operations bar
    virtual float GetOperationsWidth() { return 0; }
    virtual TSharedObjectPtr<RTexture2D> GetIcon() const
    {
        //subclass should override this function
        assert(false);
        return nullptr;
    }
    virtual CString GetTitle() const
    {
        //subclass should override this function
        assert(false);
        return U"";
    }

    virtual void BindModel(TSharedObjectPtr<REditorPageModel> InModel) ;
    TSharedObjectPtr<REditorPageModel> GetModel() const;
    bool HasUnsavedData() const;
    void SaveFile() const;

    bool Undo();
    bool CanUndo();
    virtual void PostUndo() {};
    bool Redo();
    bool CanRedo();
    virtual void PostRedo() {};

    //如果消耗了剪切操作，返回true
    virtual bool Cut();
    //如果消耗了复制操作，返回true
    virtual bool Copy();
    //如果消耗了粘贴操作，返回true
    virtual bool Paste();
    virtual bool CanCut() const;
    virtual bool CanCopy() const;
    virtual bool CanPaste() const;
protected:
    TWeakObjectPtr<REditorPageModel> BaseModel;

};